import selenium
import time,requests
from selenium import webdriver
cd=webdriver.Chrome(r'C:\Users\Architect\AppData\Local\Google\Chrome\Application\cd75.exe')
cd.set_window_size(1600,900)
cd.get(r'https://www.twitter.com/natsuiromatsuri')
try:
    otweet=cd.find_element_by_class_name('tweet-text')
except:
    requests.get('https://sc.ftqq.com/SCU28400T01ea9d7371f3207589b8c98f970d6c505c6a19975daf2.send',params={'text':'WARNING:系统崩溃','desp':'无法查找到推文元素，嵌字君崩溃。【Network Error】'})
    cd.save_screenshot('CrashReport.png')
else:
    otweet.click()
    translate=input('翻译文字：')
    info=cd.find_element_by_class_name('tweet-text')
    cd.execute_script('document.getElementsByClassName("TweetTextSize TweetTextSize--jumbo js-tweet-text tweet-text")[0].innerText="%s"'%translate)
    cd.execute_script('var org=document.getElementsByClassName("metadata")[0].innerHTML;var ps2=org+" <a>  【夏色祭工坊 翻译制作】</a>";document.getElementsByClassName("metadata")[0].innerHTML=ps2;')
    sca=cd.find_element_by_xpath('//*[@id="permalink-overlay-body"]/div/div[1]/div[1]/div')
    sca.screenshot('capt.png')
    cd.close()